package archer.framework.file.entity;

import archer.framework.file.config.FileRepositoryConfig;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 文件资源
 *
 * @author christ
 * @date 2015/9/24
 */
public class FileResource {

    @Autowired
    FileRepositoryConfig config;

    /**
     * 数据
     */
    private byte[] data;

    /**
     * 元数据
     */
    private Metadata metaData;

    public FileResource(String filename, byte[] data, String mimeType) {
        this.data = data;
        this.metaData = new Metadata(filename, mimeType);
        this.metaData.setSize(data.length);
    }

    public byte[] getData() {
        return data;
    }

    public Metadata getMetadata() {
        return metaData;
    }

    public FileResource setData(byte[] data) {
        this.data = data;
        return this;
    }

    public FileResource setMetaData(Metadata metaData) {
        this.metaData = metaData;
        return this;
    }
}